<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script src="/kissy/build/seed.js"></script>
    <script src="/kissy/src/package.js"></script>
</head>
<body>
<h1>KISSY Router Replace History Test Cases</h1>
<button id='change'>change</button>
<button id="back" onclick="history.back()" disabled>back</button>
<script>
    KISSY.use('mvc', function (S, MVC) {

        window.onbeforeunload=function(){
          return '确定要离开？';
        };

        var $ = S.all, Router = MVC.Router;

        location.replace('#');

        var r = new Router({
            routes: {
                "/go/": function () {
                    S.log('changed to: ' + 'go')
                },
                "/list/": function () {
                    S.log('changed to: ' + 'list')
                },
                "/detail/": function () {
                    S.log('changed to: ' + 'detail')
                }
            }
        });

        Router.start();

        var action = [function () {
            Router.navigate('/list/');
        }, function () {
            Router.navigate('/detail/', {
                replaceHistory: 1
            });
        }, function () {
            Router.navigate('/go/');
        }, function () {
            $('#change')[0].disabled = true;
            $('#back')[0].disabled = false;
        }];

        var actionIndex = 0;

        $('#change').on('click', function () {
            action[actionIndex++]();
        });

    });
</script>

</body>
</html>